package com.hfzy.ihk.web.oauth.server.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hfzy.ihk.facade.userCenter.entity.Resource;
import com.hfzy.ihk.facade.userCenter.entity.UserInfo;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 用于集成spring security Mapper 接口
 * </p>
 *
 * @author wws
 * @since 2018-12-28
 */
public interface UserMapper extends BaseMapper<UserInfo> {

    @Select("select * from user_info u where u.username=#{username}")
    UserInfo findUserByUserName(String username);


    UserInfo queryUserInfoByUserName(String username);

    @Select("select  r.id,r.btn_permission from user_has_resource  hr \n" +
            "LEFT JOIN resource r on r.id=hr.resource_id where r.type=2\n" +
            "union \n" +
            "select  r.id,r.btn_permission from priv_has_resource pr \n" +
            "LEFT JOIN resource r on r.id=pr.resource_id \n" +
            "LEFT JOIN priv pv on pv.id=pr.priv_id \n" +
            "LEFT JOIN role_has_priv pi on pi.priv_id=pv.id\n" +
            "LEFT JOIN user_has_role ll on ll.role_id=pi.role_id\n" +
            "LEFT JOIN user_info u on u.id=ll.user_id\n" +
            "where r.type=2 and u.username=#{userName}\n")
    List<Resource> querybtnPermissionByUserName(String userName);


}
